package com.macro.mall.portal.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.macro.mall.common.api.CommonResult;
import com.macro.mall.portal.domain.LoanPackage;
import com.macro.mall.portal.domain.Transfer;
import com.macro.mall.portal.domain.vo.PageVo;
import com.macro.mall.portal.service.ILoanPackageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
@RequestMapping("/loan")
@Api(tags = "LoanPackageController", description = "我能贷多少")
public class LoanPackageController {

    @Autowired
    private ILoanPackageService loanPackageService;

    @ApiOperation("分页查询记录")
    @RequestMapping(value = "/selectList", method = RequestMethod.POST)
    public CommonResult selectList(@RequestBody PageVo page) {
        List<LoanPackage> loanPackageIPage = null;
        try {
            loanPackageIPage = loanPackageService.selectList(page.getOpenId(), page.getPage(), page.getSize());
        } catch (Exception e) {
            e.printStackTrace();
            return CommonResult.failed("服务器异常");
        }
        return CommonResult.success(loanPackageIPage);
    }

    @ApiOperation("我能贷详情")
    @RequestMapping(value = "/getInfo", method = RequestMethod.POST)
    public CommonResult getInfo(@RequestBody String id) {
        LoanPackage loanPackageIPage = null;
        try {
            loanPackageIPage = loanPackageService.getInfo(id);
        } catch (Exception e) {
            e.printStackTrace();
            return CommonResult.failed("服务器异常");
        }
        return CommonResult.success(loanPackageIPage);
    }

    @ApiOperation("我能贷批量详情")
    @RequestMapping(value = "/getBatchInfo", method = RequestMethod.POST)
    public CommonResult getBatchInfo(@RequestBody LoanPackage loanPackage) {
        List<LoanPackage> loanPackageIPage = null;
        try {
            loanPackageIPage = loanPackageService.getBatchInfo(loanPackage);
        } catch (Exception e) {
            e.printStackTrace();
            return CommonResult.failed("服务器异常");
        }
        return CommonResult.success(loanPackageIPage);
    }
}
